<?php

class Form_ContractorForm extends Form_Custom_General {

    public function init() {

        $cus_id = $this->createElement('hidden', 'ctr_id')
                ->addFilters(array(
                    new Zend_Filter_StringTrim(),
                ))
                ->setAttribs(Array("size" => "60"));
        $this->addElement($cus_id);

        $ctr_name = $this->createElement('text', 'ctr_name')
                ->setRequired(TRUE)
                ->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => 'Name should not be blank.')))
                ->addFilters(array(
                    new Zend_Filter_StringTrim(),
                ))
                ->setAttribs(Array("size" => "60"));
        $this->addElement($ctr_name);

        $ctr_companyname = $this->createElement('text', 'ctr_companyname')
                #->setRequired(TRUE)
                ->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => 'Company name should not be blank.')))
                ->addFilters(array(
                    new Zend_Filter_StringTrim(),
                ))
                ->setAttribs(Array("size" => "60"));
        $this->addElement($ctr_companyname);
        
        
        $lgn_email = $this->createElement('text', 'lgn_email')
                ->setRequired(TRUE)
                ->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => 'Email address should not be blank.')))
                ->addValidator(new Zend_Validate_EmailAddress())
                ->addFilters(array(
                    new Zend_Filter_StringTrim(),
                    new Zend_Filter_StringToLower()
                ))
                ->setAttribs(Array("size" => "60"));
        $lgn_email->getValidator('emailAddress')->setMessage("Email address is not valid.", Zend_Validate_EmailAddress::INVALID_FORMAT);
        $this->addElement($lgn_email);


        $old_password = $this->createElement('password', 'old_password')
                ->addFilters(array(
                    new Zend_Filter_StringTrim(),
                ))
                ->setAttribs(Array("size" => "20"));
        $this->addElement($old_password);


        $password = $this->createElement('password', 'ctr_password')
                ->addFilters(array(
                    new Zend_Filter_StringTrim(),
                ))
                ->setAttribs(Array("size" => "20"));
        $this->addElement($password);

        
        $confirmpassword = $this->createElement('password', 'ctr_confirmpassword')
                ->addFilters(array(
                    new Zend_Filter_StringTrim(),
                ))
                ->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => 'Password should not be blank.')))
                ->setAttribs(Array("size" => "20"));
        $this->addElement($confirmpassword);

        
        $ctr_nature_business = $this->createElement('text', 'ctr_nature_business')
                #->setRequired(TRUE)
                ->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => 'Nature of business should not be blank.')))
                ->addFilters(array(
                    new Zend_Filter_StringTrim()
                ))
                ->setAttribs(Array("size" => "60", "cols" => "50", "rows" => "10"));
        $this->addElement($ctr_nature_business);

        
        $ctr_attention = $this->createElement('textarea', 'ctr_attention')
                #->setRequired(TRUE)
                ->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => 'Attention should not be blank.')))
                ->addFilters(array(
                    new Zend_Filter_StringTrim()
                ))
                ->setAttribs(Array("size" => "60", "cols" => "50", "rows" => "10"));
        $this->addElement($ctr_attention);

        
        $ctr_address = $this->createElement('textarea', 'ctr_address')
                #->setRequired(TRUE)
                ->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => 'Address should not be blank.')))
                ->addFilters(array(
                    new Zend_Filter_StringTrim()
                ))
                ->setAttribs(Array("size" => "60", "cols" => "50", "rows" => "10"));
        $this->addElement($ctr_address);

        
        $ctr_telephone = $this->createElement('text', 'ctr_telephone')
                #->setRequired(TRUE)
                ->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => 'Telephone number should not be blank.')))
                ->addFilters(array(
                    new Zend_Filter_StringTrim(),
                ))
                ->setAttribs(Array("size" => "60"));
        $this->addElement($ctr_telephone);

        
        $ctr_mobile = $this->createElement('text', 'ctr_mobile')
                ->setRequired(TRUE)
                ->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => 'Mobile number should not be blank.')))
                ->addFilters(array(
                    new Zend_Filter_StringTrim(),
                ))
                ->setAttribs(Array("size" => "60"));
        $this->addElement($ctr_mobile);


        $ctr_fax = $this->createElement('text', 'ctr_fax')
                #->setRequired(TRUE)
                ->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => 'Fax number should not be blank.')))
                ->addFilters(array(
                    new Zend_Filter_StringTrim(),
                ))
                ->setAttribs(Array("size" => "60"));
        $this->addElement($ctr_fax);

        
        $ctr_notes = $this->createElement('textarea', 'ctr_notes')
                #->setRequired(TRUE)
                ->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => 'Notes should not be blank.')))
                ->addFilters(array(
                    new Zend_Filter_StringTrim()
                ))
                ->setAttribs(Array("size" => "60", "cols" => "50", "rows" => "10"));
        $this->addElement($ctr_notes);
        
        $lgn_active = $this->createElement('select', 'lgn_active')
                ->setRequired(TRUE)
                ->addFilters(array(
                    new Zend_Filter_StringTrim(),
                    new Zend_Filter_StringToLower()
                ))
                ->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select status.')));
        $this->addElement($lgn_active);
        
        $submit = $this->createElement('submit', 'Save')
                ->setAttribs(Array('title' => "Save changes"));
        $this->addElement($submit);

        
        $reset = $this->createElement('reset', 'Reset')
                ->setAttribs(Array('title' => "Save changes and continue to edit"));
        $this->addElement($reset);
    }

}